Quick Start API Request
The purpose of this section is to ensure that your API key is working and that you have the formatting required to both send a POST request and receive a response, conforming to the REST API convention. Follow the steps below to send a simple request to find the employment level in Canada.
Authentication
The Data Hub API requires users to authenticate each of their API requests with their own unique API key. To authenticate each API request, add the following header to your request, and all future requests:
'x-api-key': 'API_KEY_HERE'
To locate your unique API key, which is associated with your Sandbox account:
- Navigate to https://datahub.lmic-cimt.ca/account
- Copy the API key by clicking the clipboard icon
- Place your API key in the header of your API requests
Endpoint, Indicator, and Query Strings
The API has one endpoint:
https://lmic-datahub-prod-gw-d6ow9n6v.uc.gateway.dev/lmi
Each request must contain the query parameter called 'indicator', with a value of 1-18. These values refer to indicators provided by the API.
To find the employment level in Canada (the default geography), enter the query string as seen below:
https://lmic-datahub-prod-gw-d6ow9n6v.uc.gateway.dev/lmi?indicator=1
Two other important parameters are start and end, which specify the dates of interest. To look at the employment level in 2022-03-01, edit the query string as below:
https://lmic-datahub-prod-gw-d6ow9n6v.uc.gateway.dev/lmi?indicator=1&start=20220301&end=20220331
All other parameters are also passed to the API as query strings. See the other example pages for familiarisation.
Request & Response Overview
The following is a simple POST request in CURL format:
curl --location --request POST 'https://lmic-datahub-prod-gw-d6ow9n6v.uc.gateway.dev/lmi?indicator=1' \
--header 'x-api-key: API_KEY_HERE' \
--data-raw ''
The API response:
{
"data": [
{
"source": "LFS-14100287; LFS-14100017",
"as_of_date": "2022-03-01",
"ref_date": "2022-03-01",
"data_frequency": "monthly",
"country": "Canada",
"provinces_territories": null,
"cma_en": null,
"economic_regions_en": null,
"sex_en": "Both sexes",
"age_en": "15 years and over",
"noc_level": null,
"noc_code": null,
"noc_title_en": null,
"naics_level": null,
"naics_code": null,
"naics_title_en": null,
"adjustment_en": "unadjusted",
"indicator_name_en": "Employment level",
"indicator_value": 19275900.0
}
],
"meta": {
"current_page": 1,
"total_pages": 1,
"per_page": 1000,
"total_rows": 1
}
}
Good to know points:
Always use POST requests because GET requests do not accept filters.
The API response is in JSON format with two components: data and meta . Data contains all variables, labels, and values associated with the LMI data. Meta contains information about the paginated response.
The API has a limit of 1000 records per page, so pagnation is required by the API user for large responses.
Navigate to the other API Guide pages to become more familiar with Data Hub API requests.